"""
@Uses : This file will drop the tables mentioned in the file
"""

from os import listdir
import MySQLdb


"""
site_file = "temp_sites"#"all_site_names" #44_sites
folder_path = "D:\Research\ISEC-2014\data\content"
user = "root"
password="123"
database = "isec2014"
port=3306
"""
site_file = "all_site_name" #44_sites
#E:\Sangeeta\dataset\2013_05_stack_overflow\Content\meta.bicycles.stackexchange.com
folder_path = "E:\Sangeeta\dataset\\2013_05_stack_overflow\Content"
user = "sangeetal"
password="sangeetal"
database = "sangeeta"
port=3307
#"""

db1= MySQLdb.connect(host="localhost", user=user, passwd=password,db=database, port=port)

     
table_type = "posthistory"        
        
def drop_tables():
    file = open(site_file)
    site_names = list()
    for f in file:
        site_names.append(f)
        
    for site in site_names:
        print "site=", site
        table =table_type+"_"+((str) (site)).strip()+"_aug13"
        drop_str = "drop table `"+table+"`" 
        
        
        print "drop_str=", drop_str
        cur = db1.cursor()
        cur.execute(drop_str)  
 
#drop_tables()  
table_type = "posts" 
drop_tables()  
#table_type = "users" 
#drop_tables()      